import { addFontToDoc, getStoredFontInfo } from "@utils";
import Configs from "@config";

const fontConfig = Configs.font;
/**
 *
 * @param {Document} doc
 */
export function handleFont(doc, callback = undefined) {
  getStoredFontInfo(function ({ fontinfo }) {
    const url = fontConfig.fonts_url + fontinfo.woff2;
    addFontToDoc("uighurFont", url, doc).then((fontface) => {
      doc ? doc.fonts.add(fontface) : document.fonts.add(fontface);
      callback && callback(fontface);
    });
  });
}
